﻿<%@ Page Language="C#" MasterPageFile="~/Theme/Stander/Stander.master" AutoEventWireup="true" CodeFile="PayoutRecord.aspx.cs" Inherits="Bill_PayoutRecord" Title="编辑付款单－－财务部" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
    <asp:ScriptManagerProxy id="ScriptManagerProxy1" runat="server">
    </asp:ScriptManagerProxy>
    <script type="text/javascript" >
    function Check()
    {
        var DeductFromAdvance=document.getElementById('<% =txtDeductFromAdvance.ClientID %>');
        var DeductFromBrokerage = document.getElementById('<%=txtDeductFromBrokerage.ClientID %>');
        var Payouy = document.getElementById('<%=txtPayout.ClientID %>');
        if(0==SumPayout())
        {
            alert("没有付款金额，请在你想要的付款方式下输入金额大小！");
            return false;
        }
        else
        {
            if(confirm("确认所有信息正确并保存？"))
            {return true;}
            else{return false;}
        }
    }
    function SumPayout()
    {
        var DeductFromAdvance=document.getElementById('<% =txtDeductFromAdvance.ClientID %>');
        var DeductFromBrokerage = document.getElementById('<%=txtDeductFromBrokerage.ClientID %>');
        var Payout = document.getElementById('<%=txtPayout.ClientID %>');
        var TotalPayout=document.getElementById('<% =txtTotalPayout.ClientID %>');
        TotalPayout.value=0;
        if(DeductFromAdvance.value!="" && DeductFromAdvance.value!="没余额可扣"){TotalPayout.value = eval(TotalPayout.value) + eval(DeductFromAdvance.value);}
        if(DeductFromBrokerage.value!="" && DeductFromBrokerage.value!="没余额可扣"){TotalPayout.value = eval(TotalPayout.value) + eval(DeductFromBrokerage.value);}
        if(Payout.value!="" && Payout.value!="没余额可扣"){TotalPayout.value = eval(TotalPayout.value) + eval(Payout.value);}
        return TotalPayout.value;
    }
    </script>
    <fieldset>
    <h1 class="pagetitle">
        编辑付款单
        <asp:Button ID="btnBack" runat="server" Text="返回上一级" CausesValidation="False" Font-Size="11pt" Height="25px" Width="100px" OnClick="btnBack_Click" /></h1>
        <table border="0" cellpadding="0" cellspacing="0" style="font-size: 10pt;" id="TABLE1">
            <tr>
                <td colspan="4" style="font-size: 11pt;">
                    <asp:Label ID="lblOrderId" runat="server" Visible="false" ></asp:Label>
                    付款媒介:<asp:Label ID="lblMediaName" runat="server" ForeColor="#FF3300"></asp:Label>&nbsp;&nbsp;&nbsp;
                    对应的客户:<asp:Label ID="lblCustomerName" runat="server" ForeColor="#FF3300"></asp:Label>
                  </td>
             </tr>
             <tr>
                  <td>应付款:</td><td><asp:Label ID="lblFinalPayout" runat="server" Font-Size="11pt" ForeColor="#FF3300"></asp:Label>&nbsp;&nbsp;&nbsp;</td>
                  <td>总已付款:</td><td><asp:Label ID="lbAlreadyPayout" runat="server" Font-Size="11pt" ForeColor="#FF3300"></asp:Label>&nbsp;&nbsp;&nbsp;</td>
                  <td>清单状态:</td><td><asp:Image ID="imgBillAudit" runat="server" />&nbsp;&nbsp;</td>
                  <td>媒介订单状态:</td><td><asp:Image ID="imgMediaAudit" runat="server" /></td>
            </tr></table>
    </fieldset>
    <fieldset>
        <h1 class="pagetitle">该订单下的付款记录</h1>
        <br />
        <asp:GridView ID="gvPayoutListByOrderId" runat="server" AutoGenerateColumns="False" CssClass="normal mouseOver" 
        OnRowDataBound="gvPayoutListByOrderId_RowDataBound" OnRowDeleting="gvPayoutListByOrderId_RowDeleting">
            <Columns>
                <asp:BoundField DataField="Id" HeaderText="付款单号" />
                <asp:BoundField DataField="DeductFromAdvance" DataFormatString="{0:c}" HeaderText="从预付款余额扣除"
                    HtmlEncode="False" />
                <asp:BoundField DataField="DeductFromBrokerage" DataFormatString="{0:c}" HeaderText="从返点余额扣除"
                    HtmlEncode="False" />
                <asp:TemplateField HeaderText="总付款金额">
                    <ItemTemplate>
                        <asp:Label ID="lblPayout" runat="server"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="PayoutDate" HeaderText="付款日期" DataFormatString="{0:d}" HtmlEncode="False" />
                <asp:BoundField DataField="Description" HeaderText="财务备注" SortExpression="Description" >
                </asp:BoundField>
                <asp:HyperLinkField DataNavigateUrlFields="Id,OrderId" 
                    DataNavigateUrlFormatString="PayoutRecord.aspx?PayoutRecordId={0}&OrderId={1}"
                    HeaderText="编辑" Text="修改" />
                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
                            Text="删除" OnClientClick='return confirm("你确认要删除该记录吗？");'></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EmptyDataTemplate>
                暂无任何记录.
            </EmptyDataTemplate>
        </asp:GridView>
        <ajaxToolkit:CalendarExtender ID="defaultCalendarExtender" runat="server" Format="yyyy-M-d" PopupButtonID="selectDateImageBtn" TargetControlID="txtPayoutDate">
        </ajaxToolkit:CalendarExtender>
        <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" Format="yyyy-M-d" TargetControlID="txtPayoutDate">
        </ajaxToolkit:CalendarExtender><br />
         <asp:PlaceHolder ID="PayoutRecordEditPlaceHolder" runat="server">
            <h1 class="block" id="h1Title" runat="server">增加新付款</h1>
            <table border="0" cellpadding="0" cellspacing="0" style="font-size: 10pt">
            <tr>
                <td style="width: 146px; height: 25px; text-align: right">
                    当前媒介预付款余额：</td>
                <td style="width: 148px; height: 25px; color: #0099ff;">
                    <asp:Label ID="lblAdvanceBalance" runat="server" ></asp:Label></td>
                <td style="width: 125px; height: 25px; text-align: right">
                    当前媒介返点余额：</td>
                <td style="width: 204px; height: 25px">
                    <asp:Label ID="lblBrokerageBalance" runat="server" ForeColor="#0099FF" ></asp:Label></td>
            </tr>
            <tr>
                <td style="width: 146px; height: 25px; text-align: right">
                    从媒介预付款中扣除：</td>
                <td style="width: 148px; height: 25px; color: #0099ff;">
                        <asp:TextBox ID="txtDeductFromAdvance" runat="server" onKeyUp="SumPayout();" Width="95px" ForeColor="#0099FF">
                        </asp:TextBox>
                        <asp:CompareValidator ID="valcAdvanceBalace" runat="server" ControlToValidate="txtDeductFromAdvance"
                        ErrorMessage="必须少于预付款余额" Operator="LessThanEqual" Type="Double" Display="Dynamic" ValidationGroup="valCheck">
                        </asp:CompareValidator></td>
                <td style="width: 125px; height: 25px; text-align: right">
                    从返点中扣除：</td>
                <td style="width: 204px; height: 25px">
                        <asp:TextBox ID="txtDeductFromBrokerage" runat="server" onKeyUp="SumPayout();" Width="95px" ForeColor="#0099FF">
                        </asp:TextBox>
                    <asp:CompareValidator ID="valcBrokerage" runat="server" ControlToValidate="txtDeductFromBrokerage"
                        Display="Dynamic" ErrorMessage="必须少于返点余额" Operator="LessThan" Type="Double" ValidationGroup="valCheck">
                        </asp:CompareValidator></td>
            </tr>
            <tr>
                <td style="width: 146px; height: 10px; text-align: right">
                </td>
                <td colspan="3" style="height: 10px">
                </td>
            </tr>
            <tr>
                <td style="width: 146px; height: 28px; text-align: right">
                    现金付款金额：</td>
                <td style="width: 148px; height: 25px; color: #0099ff;">
                        <asp:TextBox ID="txtPayout" runat="server" onKeyUp="SumPayout();" Width="95px" ForeColor="#0099FF">
                        </asp:TextBox>
                        <asp:RegularExpressionValidator ID="valrePayout" runat="server" ControlToValidate="txtPayout" Display="Dynamic"
                            ErrorMessage="必须为数字" ValidationExpression="[0-9.]*" ValidationGroup="valCheck">
                            </asp:RegularExpressionValidator></td>
                <td style="width: 125px; height: 28px; vertical-align: bottom;">
                    &nbsp;财务备注：</td>
                <td style="width: 204px; height: 28px">
                        </td>
            </tr>
            <tr>
                <td style="width: 146px; height: 25px; text-align: right">
                    总金额：</td>
                <td style="width: 148px; height: 25px; color: #0099ff;">
                    <asp:TextBox ID="txtTotalPayout" runat="server" ReadOnly="True" Width="95px" ForeColor="#F2560B"></asp:TextBox></td>
                <td colspan="2" rowspan="2">
                    &nbsp;<asp:TextBox ID="txtDescription" runat="server" Width="250px" ForeColor="#0099FF" Height="38px" TextMode="MultiLine"></asp:TextBox></td>
            </tr>
            <tr>
                <td style="width: 146px; height: 25px; text-align: right">
                    媒介支付日期：</td>
                <td style="width: 148px; height: 25px; color: #0099ff;">
                        <asp:TextBox ID="txtPayoutDate" runat="server" Width="95px" ForeColor="#0099FF" ToolTip="单击选择日期"></asp:TextBox>
                        <asp:ImageButton ID="selectDateImageBtn" runat="server" alt="选择日期" ImageUrl="../theme/stander/img/calendar.png" OnClientClick="return false;" />
                    <asp:RequiredFieldValidator ID="valrPayoutDate" runat="server" ControlToValidate="txtPayoutDate"
                        Display="Dynamic" ErrorMessage="日期不能为空" ValidationGroup="valCheck"></asp:RequiredFieldValidator>
                    <asp:CompareValidator ID="valcDateType" runat="server" ControlToValidate="txtPayoutDate"
                        Display="Dynamic" ErrorMessage="日期格式错误" Operator="DataTypeCheck" Type="Date" ValidationGroup="valCheck"></asp:CompareValidator></td>
            </tr>
            <tr>
                <td colspan="4" rowspan="1">
                <div style="text-align:center">
                <asp:Button ID="btnSavePayout" runat="server" Text="确认付款" OnClick="btnSavePayout_Click" OnClientClick='if(!Check()) return false;' ValidationGroup="valCheck" />&nbsp;
                        <asp:Button ID="btnNew" runat="server" Text="取消修改" OnClick="btnNew_Click" Visible="False" CausesValidation="False" /></div>
                </td>
            </tr>
        </table>
        </asp:PlaceHolder>
        </fieldset>
</asp:Content>
